<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    hello
  </div>
  <script>
    // 模拟 Vue 中的 data 选项
    let data = {
      msg: 'hello',
      count: 10
    }
    // 模拟 Vue 的实例
    let vm = {}
    let app = document.getElementById('app');
    Object.keys(data).forEach(key => {
      // console.log(key);
      Object.defineProperty(vm, key, {
        enumerable: true,
        configurable: true, 
        get(){
          return data[key]
        },
        set(val){
          data[key] = val;
          app.innerHTML = val;
        }
      })
    });
    vm.msg = 'world'
  </script>
</body>

</html>